package org.evs.odesk.programmingSkills;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * 
 * Write a program which will accept three sentences (one sentence per line) and print the words having Initial Caps
 * within the sentences. Below is an example.
 * 
 * Here is an example. If the below three sentences are given to the program as input,
 * 
 * This is a Program
 * Coding test of Initial Caps
 * the program Will Test You
 * 
 * Then, the output would look like:
 * 
 * This
 * Program
 * Coding
 * Initial
 * Caps
 * Will
 * Test
 * You
 * 
 * @author Dmitry Kalachov
 * 
 */
public class Task_WriteCapitalWords {

    public static void main(String[] args) throws IOException {
        // test();
        real();
    }

    /**
     * @throws IOException 
     * 
     */
    private static void real() throws IOException {
        BufferedReader consoleReader = new BufferedReader(new InputStreamReader(System.in));
        String firstLine = consoleReader.readLine().trim();
        String secondLine = consoleReader.readLine().trim();
        String thirdLine = consoleReader.readLine().trim();

        String[] firstLineWords = firstLine.split(" ");
        String[] secondLineWords = secondLine.split(" ");
        String[] thirsLineWords = thirdLine.split(" ");

        printWordsWithFirstUpLetter(firstLineWords);
        printWordsWithFirstUpLetter(secondLineWords);
        printWordsWithFirstUpLetter(thirsLineWords);
    }

    private static void test() {
        printWordsWithFirstUpLetter("This is a Program".split(" "));
        printWordsWithFirstUpLetter("Coding test of Initial Caps".split(" "));
        printWordsWithFirstUpLetter("the program Will Test You".split(" "));
    }

    public static void printWordsWithFirstUpLetter(String[] words) {
        for (String s : words) {
            char firstChar = s.charAt(0);
            if (Character.isUpperCase(firstChar)) {
                System.out.println(s);
            }
        }
    }

}
